<?php
	include_once '../inc/config.inc.php';
	include_once '../inc/mysql.inc.php';
	include_once '../inc/tool.inc.php';
	if(isset($_POST['submit']))
	{
		$link=connect();
		$check_flag='add';
		//验证填写信息
		include 'inc/check_news_manager.inc.php';
		$query="insert into news
(title,author,content,lasttime,ip,source)
values
(
'{$_POST['title']}','{$_POST['author']}',
'{$_POST['content']}',NOW(),'{$_SERVER["REMOTE_ADDR"]}','{$_POST['source']}')";
		execute($link,$query);
		if(mysqli_affected_rows($link)==1)
		{
			skip('news_manager.php','ok','恭喜你，添加成功！');
		}else
		{
			skip('news_manager.php','error','对不起，插入数据失败,请重试！');
		}
		exit();

	}
	$template['title']='添加新闻页';
	$template['keyword']='新闻管理页';
	$template['css']=array('style/public.css');
?>
<?php include 'inc/header.inc.php';  ?>
<div id="main">
	<div class="title" style="margin-bootom:20px;">添加新闻</div>
	<form method="POST">
		<table class="au">
				<tr>
					<td>标题</td>
					<td><input name="title" type="text" /></td>
					<td>
						不得为空，最大不得超过200个字符
					</td>
				</tr>
				<tr>
					<td>作者</td>
					<td><input name="author" type="text" /></td>
					<td>
						填写中/英文名称
					</td>
				</tr>
				<tr>
					<td>内容</td>
					<td><textarea name="content"></textarea></td>
					<td>
						不超过500字符
					</td>
				</tr>
				<tr>
					<td>发布时间</td>
					<td><input name="lasttime" type="text" /></td>
					<td>
						不得为空
					</td>
				</tr>
				<tr>
					<td>ip</td>
					<td><input name="ip" type="text" /></td>
					<td>
						不得为空
					</td>
				</tr>
				<tr>
					<td>来源</td>
					<td><input name="source" type="text" /></td>
					<td>
						不得为空
					</td>
				</tr>
			</table>
			<?php /*鼠标移动变成手型*/ ?>
			<input style="cursor:pointer;" class="btn" type="submit" name="submit" value="添加" />
	</form>
</div>
<?php include 'inc/footer.inc.php'; ?>